package com.demo.springboot;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    private MeterRegistry meterRegistry;

    @GetMapping("/user/home")
    public String home(){
        Counter counter =  meterRegistry.counter("user.home.request.count");
        counter.increment(1);
        return "home";
    }

    @GetMapping("/pad/price")
    public String price(@RequestParam("p") double price){
        meterRegistry.gauge("product.pad.price",price);
        return "Pad Price";
    }
}
